<?php
require '../config.php';
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="author" content="www.frebsite.nl" />
		<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
		<meta name="robots" content="noindex, nofollow" />
		<title>后台管理系统</title>
        <link rel="stylesheet" href="../public/css/docs.css" />
		<link rel="stylesheet" href="../kindeditor/themes/default/default.css" />
		<script src="../kindeditor/kindeditor.js"></script>
		<script src="../kindeditor/lang/zh_CN.js"></script>
		<script>
			KindEditor.ready(function(K) {
				window.editor = K.create('#addContent',{
					height: '400px',
items: [
        'source', '|','bold','italic','fontsize','|','hr','emoticons','|','fullscreen'
		],
		afterBlur:function(){this.sync();}
				});
				var editor = K.editor({
					allowFileManager : true
				});
				K('#imgFile').click(function() {
					editor.loadPlugin('image', function() {
						editor.plugin.imageDialog({
							showRemote : false,
							imageUrl : K('#imgUrl').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#imgUrl').val(url);
								K('#imgPreview').attr('src',url);
								editor.hideDialog();
							}
						});
					});
				});
			});
		</script>
</head>
<body>
<div id="page">
   <div id="header">写博客 - 后台管理系统<a href="#" class="right" id="out"></a></div>  
   <div id="content">
        <div id="articlebox">
			        <p><a href="#" id="goback" style="text-decoration:none;font-weight:bold;color:#1d953f;font-size:12px;"><< 返回</a></p>
			        <h1> + 写博客</h1>	
			        <form id="form1">
						栏目:   <select name="catalog" id="catalog" style="width:100%;height:30px;">
                                <option value='select'> -/- 请选择 -/-</option>
						        <?php
                                    $result = mysql_query("select * from catalog");
                                    while($row = mysql_fetch_array($result)){
                                    echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
                                    }
								?>
						        </select><br />
						标题：
						<div>
						        <input type="text" name="title" id="title" style="width:100%;height:30px;"/>
						</div>
						内容：
						<div>
						         <textarea style="width:100%;" name="content" id="addContent"></textarea>
						</div>
						封面图片：
						<div>
						         <input type="text" name="image" id="imgUrl" value="" /> <input type="button" id="imgFile" value="选择图片" />
						</div>
						<br />
						<div>
					             <input type="submit" name="submit" value="提交" style="width:100%;height:40px;background:#1d953f;border:0;color:#fff;font-weight:bold;line-height:40px" />
					    </div>
					</form>
        </div>	
   </div>
</div>
<script type="text/javascript" src="../public/js/jquery-1.11.0.min.js"></script>
<script>
$(function(){
	$('#out').bind('click',function(){
		if(confirm('确认离开?')){
            window.location.href = '../index.php';
		}else{
            return;
		}
	});
	$('#show_menu').bind('click',function(){
           $(this).children('div#menu').slideToggle();
	});
	$('#goback').bind('click',function(){
		   window.location.href = 'func.php';
	});
	$('input[type=submit]').bind('click',function(){
		if($('#catalog').val() == 'select' || $('#title').val() == '' || $('#addContent').val() == ''){
               alert('请填写完整再提交!');
		}else{
			$('#form1').attr('method','post');
			$.post('./doAdd.php',$('#form1').serialize(),function(data){
				if(data){
                   window.location.href = './func.php';
				}else{
                   alert('增加博文失败!');
				}
			});
		}
        return false;
	});
})
</script>
</body>
</html>
